package com.jk.controller;


import com.jk.entity.Coupon;
import com.jk.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping("coupon")
public class CouponController {

    @Autowired
    private CouponService couponService;

    @RequestMapping("queryCouponById")
    public List<Coupon> queryCouponById(HttpServletRequest request) throws ParseException {
        List<Coupon> list = couponService.queryCouponById(request);
        return list;
    }

    @RequestMapping("queryCoupon")
    public List<Coupon> queryCoupon(){
        List<Coupon> list = couponService.query();
        return list;
    }

    @RequestMapping("insertCoupon")
    public void insertCoupon(HttpServletRequest request,String id){
        Coupon coupon = couponService.queryById(id);
        couponService.insertCoupon(request,coupon);
    }

    @RequestMapping("deleteCoupon")
    public void deleteCoupon(HttpServletRequest request,String id){
        couponService.deleteCoupon(request,id);
    }

    @RequestMapping("getCoupon")
    public List<Coupon> getCoupon(HttpServletRequest request){
        List<Coupon> list = couponService.getCoupon(request);
        return list;
    }


}
